package com.base.controller;

import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.base.comm.CommContent;
import com.base.po.voip.Notices;
import com.base.service.LogsService;
import com.base.service.NoticesService;
import com.base.utils.IP;
import com.base.utils.Produce;

/**
 * 添加帮助中心信息服务端
 * 
 * @author f
 *
 */
@Controller
@RequestMapping("/admin")
public class add_Notices {

	@Autowired
	private LogsService logsService;// log日志
	@Autowired
	private NoticesService noticesService; // 帮助中心信息

	// 添加帮助中心信息
	@RequestMapping(value = "/toAddNotices", method = RequestMethod.POST)
	public @ResponseBody int toAddNotices(HttpServletRequest request, Notices notices) throws Exception {
		String userid = (String) request.getSession().getAttribute("adminUserId"); // 用户登录ID
		if (userid == null) return -1; // 未登录
		notices.setId(Produce.getUUID()); // 设置参数 主键ID
		notices.setAgentid(userid); // 代理商ID
		notices.setCreatetime(Produce.getNowDate()); // 创建时间
		notices.setType(2);// 类型 2
		notices.setDatastatus(true); // 数据状态
		logsService.insert(CommContent.TYPE_CREATE, CommContent.LOGS_XIAOXI + "配置帮助中心信息",
				(String) request.getSession().getAttribute("userNick"), true, IP.getIpAddr(request));
		return noticesService.insertSelective(notices); // 添加
	}
}
